﻿// Sheego.Service.X400
// Copyright(C) 2015 Schwab Versand GmbH
//
// This source file is subject to the Microsoft Public License(Ms-PL).
// http://www.opensource.org/licenses/ms-pl.html
// All other rights reserved.
using Sheego.Service.X400.Job.Shared.Parser;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sheego.Service.X400.Job.Impl.Parser
{
    class EDIFACTParserStream : IEDIFACTParserStream
    {


        #region IEDIFACTParserStream Members

        public void Write(string head, List<string[]> tail)
        {

            switch (head)
            {
                case "UNH":
                    if (tail.Count >= 2 && tail[1].Length >= 1)
                    {
                        MessageType = tail[1][0];
                    }
                    else
                    {
                        MessageType = "ERROR";
                    }
                    break;
            }

        }

        public string MessageType { get; set; }

        #endregion

        #region IDisposable Members

        // Flag: Has Dispose already been called?
        bool disposed = false;

        // Public implementation of Dispose pattern callable by consumers.
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        // Protected implementation of Dispose pattern.
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
                return;

            if (disposing)
            {
                // Free any other managed objects here.
                //
            }

            // Free any unmanaged objects here.
            //
            disposed = true;
        }

        #endregion
    }
}
